package com.examples.controller;

import com.examples.application.IsvProduceApplicationService;
import com.examples.application.dto.IMessageResp;
import com.examples.application.dto.IsvProduceReq;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * SaaS类商品接入示例工程
 */
@RestController
@RequestMapping(value = "/isv/produce")
public class IsvProduceController {
    private final IsvProduceApplicationService isvProduceApplicationService;

    @Autowired
    public IsvProduceController(IsvProduceApplicationService isvProduceApplicationService) {
        this.isvProduceApplicationService = isvProduceApplicationService;
    }

    /**
     * SaaS生产接口请求处理
     *
     * @param isvProduceReq 请求体
     * @param request       请求
     * @return response      返回
     */
    @PostMapping(value = "")
    @ResponseBody
    public IMessageResp processProduceReq(@RequestBody IsvProduceReq isvProduceReq, HttpServletRequest request) {
        return isvProduceApplicationService.processProduceReq(isvProduceReq, request);
    }
}

